package com.wzs.rpc.protocol;

import lombok.Getter;

@Getter
public enum ProtocolMessageStatusEnum {
    OK(20,"ok"),
    BAD_REQUEST(40,"badRequest"),
    BAD_RESPONSE(50,"badResponse");
    private int code;
    private String desc;
    ProtocolMessageStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code获取枚举
     */
    public static ProtocolMessageStatusEnum getEnumByValue(int code) {
        for (ProtocolMessageStatusEnum protocolMessageStatusEnum : ProtocolMessageStatusEnum.values()) {
            if (protocolMessageStatusEnum.getCode()==code) {
                return protocolMessageStatusEnum;
            }
        }
        return null;
    }
}
